package org.example.design.mediator.test1;

import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * @author huangshen
 * @version 0
 * @description 表示复选框的类
 * @since 2022/2/11 10:22
 */
public class ColleagueCheckBox extends Checkbox implements Colleague, ItemListener {

    private Mediator mediator;

    public ColleagueCheckBox(String caption, CheckboxGroup group, boolean state) {
        super(caption, group, state);
    }

    /**
     * 传递仲裁者示例
     *
     * @param mediator 仲裁者
     */
    @Override
    public void setMediator(Mediator mediator) {
        this.mediator = mediator;
    }

    /**
     * 仲裁者下达的指示 启用为true 停用为false
     *
     * @param enabled 指示
     */
    @Override
    public void setColleagueEnabled(boolean enabled) {
        setEnabled(enabled);
    }

    @Override
    public void itemStateChanged(ItemEvent e) {
        mediator.colleagueChanged();
    }
}
